#pragma once

#include <bofcl_eclic_clicint.h>

// clicintattr寄存器的定义
typedef struct {
	u8_s vector_mode : 1;
	u8_s trig : 2;
	u8_s : 5;
} eclic_clicintattr_expl_s;

_Static_assert(sizeof(eclic_clicintattr_expl_s) == 1,
	       "Struct eclic_clicintattr_expl_s defined error!");

// ECLIC中断属性项定义
typedef struct {
	uint8_bool_s inter_flag;
	uint8_bool_s inter_en;
	eclic_clicintattr_expl_s attr;
	u8_s level_priority;
} __attribute__((aligned(4))) eclic_clicint_expl_s;

_Static_assert(sizeof(eclic_clicint_expl_s) == 4,
	       "Struct eclic_clicint_expl_s defined error!");

// 设置clicint数组第i个元素（中断属性）的值（配置项为eclic_clicint_s型）。
static inline void eclic_setup_inter_by_q(u32_s eclic_q, u32_s th,
					  eclic_clicint_s clicint) {
	eclic_wreg_clicint_s_by_q(eclic_q, th, clicint);
}

// 设置clicint数组第i个元素（中断属性）的值（配置项为eclic_clicint_expl_s型）。
static inline void eclic_setup_inter_expl_by_q(u32_s eclic_q, u32_s th,
					       eclic_clicint_expl_s clicint) {
	union {
		eclic_clicint_expl_s e;
		eclic_clicint_s r;
	} er = {
		.e = clicint,
	};
	eclic_setup_inter_by_q(eclic_q, th, er.r);
}
